<template>
	<cl-page>
		<view class="page-set">

			<cl-text value="消息通知" :margin="[30, 0, 20, 20]" block />

			<cl-list :radius="16">
				<cl-list-item label="系统消息通知" :arrowIcon="false">
					<cl-switch size="small" v-model="isPush" @change="changePush"/>
				</cl-list-item>
			</cl-list>

			<cl-text value="App内" :margin="[30, 0, 20, 20]" block />

			<cl-list :radius="16">
				<cl-list-item label="震动" :arrowIcon="false">
					<cl-switch size="small" v-model="vibrate" @change="changeVibrate"/>
				</cl-list-item>
			</cl-list>
		</view>
	</cl-page>
</template>

<script lang="ts" setup>
	import { onReady,onShow } from "@dcloudio/uni-app";
	import { useApp, useCool, useStore } from "/@/cool";
	import { useUi } from "/$/cool-ui";
	import { computed, ref } from "vue";
	import { isTurnedOnPush,trunOffPush,turnOnPush,storage } from "/@/cool/utils";
	const { router, upload } = useCool();
	const { user } = useStore();
	const ui = useUi();
	const app = useApp();
	const form = true;
	const isBattery = ref(false)
	const isPush=ref(true)
	const vibrate=ref(storage.get('vibrate'))
	onShow(()=>{
		isPush.value=isTurnedOnPush()&&user.info?.push==1
	})
	function changeVibrate(res){
		vibrate.value=res
		storage.set('vibrate',res)
		console.log(res,storage.get('vibrate'))
		
	}
	function changePush(res){
		res?turnOnPush():trunOffPush()
	}
</script>

<style lang="scss" scoped>
	.page-set {
		padding: 20rpx 24rpx;

	}
</style>